<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第 10 题</title>
    <script type="text/javascript">
        /*
            10、将数组中值为 0 的项去掉，将不为 0 的值存入一个新的数组，生成新的数组。
        */

        // 新建一个数组
        var oArr = [1, 0, 1, 0, 2, 0, 0, 4, 3, 0, 10];

        // 新建一个数组
        var oArr1 = [];
        for (var a = 0; a < oArr.length; a++) {
            for (var b = a + 1; b < oArr.length; b++) {
                if (oArr1.indexOf(oArr[b]) === -1 && oArr[b] !== 0) {
                    oArr1.push(oArr[b]);
                    b--;
                }
            }
        }
        console.log(oArr1.sort((a, b) => { return a - b }));
    </script>
</head>

<body>

</body>

</html>